package com.ouken.com;

import com.gen.tool.SoundPlayer;
//import com.ouken.tool.MplayerTool;
import com.ouken.tool.MyApp;
import com.ouken.tool.RanklistAdapter;
import com.ouken.tool.RoomlistAdapter;

import android.app.Activity;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class RanklistActivity extends Activity {
	 
	  @Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		SoundPlayer.pauseMusic();
	}
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		SoundPlayer.startMusic();
	}
	private String[] contents = {"OK","OK",
			 					  "name","100",
			 					 "name","100",
			 					"name","100",
			 					"name","100",
			 					"name","100",
			 					"name","100",
			 					"myRank"};
	 	private MyApp appState;
		private SharedPreferences userInfo;
		private ListView ranklistView;
		private ImageButton ib_back;
		//private MplayerTool mplayerTool ;
		private TextView myRank;
		private TextView myName;
		private TextView myPoint;
		
		private void initView(){
			userInfo = getSharedPreferences("user_info", 0);
			appState = ((MyApp)getApplicationContext());
			//appState.setMusic(userInfo.getString("MUSIC", "ON").equals("ON"));
			appState.addActivity(RanklistActivity.this);
			
			ranklistView = (ListView)findViewById(R.id.ranklistActivity_lv_ranklistView);
			ib_back = (ImageButton)findViewById(R.id.ranklistActivity_ib_back);
			//mplayerTool = new MplayerTool(RanklistActivity.this);
			
			myRank = (TextView)findViewById(R.id.ranklistActivity_tv_myrank);
			myName = (TextView)findViewById(R.id.ranklistActivity_tv_myname);
			myPoint = (TextView)findViewById(R.id.ranklistActivity_tv_mypoint);
			
			Bundle extras = getIntent().getExtras(); 
			if(extras!=null) contents = extras.getString("result").split(",");
			
		}
	public void onCreate(Bundle savedInstanceState) {
		   
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ranklist);
        initView();
        
        ib_back.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				SoundPlayer.playSound(R.raw.keypress_common);
				//mplayerTool.playButtonPressed(RanklistActivity.this);
				RanklistActivity.this.finish();
			}
		});
        
        
        RanklistAdapter adapter=new RanklistAdapter(this,contents);  
        ranklistView.setAdapter(adapter);
        
        myRank.setText(contents[14].toString());
        myName.setText(appState.getNickName().toString());
        myPoint.setText(contents[13].toString());
        
        
	}
}
